[WC-3322]: Fix slider and range-slider decimal places formatting#2220
[WC-3322]: Fix slider and range-slider decimal places formatting#2220samuelreichert wants to merge 12 commits into
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
4e14487 to
945997f
Compare
This comment was marked as outdated.
This comment was marked as outdated.
945997f to
98f491a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
07fc177 to
691462a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
fce3bc3 to
955eda7
Compare
This comment was marked as outdated.
This comment was marked as outdated.
955eda7 to
0fbf863
Compare
This comment was marked as outdated.
This comment was marked as outdated.
0fbf863 to
457a610
Compare
This comment was marked as outdated.
This comment was marked as outdated.
457a610 to
5a05fd6
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
6b578ae to
f4aefab
Compare
This comment was marked as outdated.
This comment was marked as outdated.
92cb4a7 to
04fed6d
Compare
This comment was marked as outdated.
This comment was marked as outdated.
AI Code Review
What was reviewed
Skipped (out of scope):
Findings🔶 Medium —
|
c49d36d to
0020512
Compare
AI Code Review
What was reviewed
Skipped (out of scope): Findings
|
…eparator Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace manual toFixed + decimal-separator swapping with the value attribute's own Mendix NumberFormatter, overriding only decimalPrecision via withConfig. The locale decimal separator and thousands grouping now follow the user's session locale and the attribute's groupDigits setting automatically. Mark keys remain rounded with parseFloat(rawValue.toFixed(dp)) (always "." based, locale-safe) so rc-slider positions dots where their labels read. Fix E2E context expectations to match the model's decimalPlaces=1 output (0.0 / 20.0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…imal places Replace raw .toString() / number in mark labels and numeric tooltips with createValueFormatter — the same pattern used in slider-web. Marks use lowerBoundAttribute.formatter; each tooltip handle uses its own formatter (lower for index 0, upper for index 1). The locale decimal separator, thousands grouping, and decimalPlaces are now all respected. Add unit tests for createValueFormatter (helpers.spec.ts) and createMarks (marks.spec.ts) mirroring the slider-web coverage. Update editorPreview to pass a deterministic preview formatter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o widget-plugin-platform createValueFormatter and createMarks extracted to widget-plugin-platform/utils so both slider-web and range-slider-web consume a single implementation without duplication. Tests moved to platform; duplicate tests removed from widget packages. Range-slider-web now uses a single formatter derived from lowerBoundAttribute. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…idget-plugin-platform
…aces=1 output Test project widget has decimalPlaces=1, so marks now render "0.0"/"100.0". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6dddf78 to
474d698
Compare
Pull request type
Bug fix (non-breaking change which fixes an issue)
Description
When
decimalPlacesis configured on the Slider or Range Slider widget, displayed values were silently stripping trailing zeros and ignoring the user's locale:10.00rendered as10,9.20rendered as9.2Root causes:
marks.ts—parseFloat(value.toFixed(n)).toString()round-tripped through a number, discarding trailing zeros. Fixed by keeping the formatted string as the label and usingparseFloatonly for the numeric key (so rc-slider positions dots correctly even when the decimal separator is a comma).createHandleRender.tsx(Slider) /Container.tsx(Range Slider) — tooltip overlay receivedrestProps.value(raw RC Slider number). Fixed by passing aValueFormatterderived from the attribute's own MendixNumberFormatter, so the decimal separator and thousands grouping follow the user's session locale.Shared logic extracted to
widget-plugin-platform:createValueFormatterandcreateMarkswere duplicated across both widgets. They have been moved topackages/shared/widget-plugin-platform/src/utils/so both widgets consume a single implementation. Tests live in the shared package only.Range Slider specifics:
Uses a single formatter derived from
lowerBoundAttributefor both marks and tooltips (both handles). The attribute formatter already carries the correct locale settings so there is no need for a separate formatter per handle.What should be covered while testing?
Slider:
decimalPlaces = 2andNumber of markers > 0.0.00,5.00,10.00— not0,5,10.10.00, not10.9.50.decimalPlaces = 0— labels and tooltip show integers, no regression.,not..Range Slider:
10.00.decimalPlaces = 0— no regression.